package com.dongdongqiang.daogenerator.sqlbuilder.mysql;

import com.dongdongqiang.daogenerator.sqlbuilder.QuerySQLBuilder;

/**
 * Created by ZZB on 2017/10/22.
 */
public class MysqlQuerySQLBuilder implements QuerySQLBuilder {
    private static final String QUERY_BY_FIELD_SQL = "SELECT * from {tableName} where {fieldName} = ?";
    private static final String COUNT_BY_FIELD_SQL = "SELECT count(*) from {tableName} where {fieldName} = ?";

    @Override
    public String queryByFieldSQL(String tableName, String field) {
        return QUERY_BY_FIELD_SQL.replace("{tableName}",tableName)
                .replace("{fieldName}", "`"+field+"`");
    }

    @Override
    public String countByFieldSQL(String tableName, String field) {
        return COUNT_BY_FIELD_SQL.replace("{tableName}",tableName)
                .replace("{fieldName}","`"+ field+"`");
    }

}
